package com.ruoyi.voucher.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.voucher.dao.PageDao;
import com.ruoyi.voucher.domain.FxyFinancialVoucher;
import com.ruoyi.voucher.domain.FxyFinancialVoucherDetails;
import com.ruoyi.voucher.service.VoucherService;
import com.ruoyi.voucher.vo.FxyFinancialVoucherDetailsVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

import static com.ruoyi.common.core.utils.PageUtils.startPage;


/**
 * @Author
 * @Date 2025/2/25 9:33
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/voucher")
public class VoucherController extends BaseController {
    @Autowired
    VoucherService voucherService;

    /**
     * 插入凭证
     * @param fxyFinancialVoucher
     * @return 返回结果
     */
//    @RequiresPermissions("voucher:voucher:voucherInsert")
    @PostMapping("/voucherInsert")
    public R voucherInsert(@RequestBody List<FxyFinancialVoucher> fxyFinancialVoucher) {
        R r = voucherService.insertVoucher(fxyFinancialVoucher);
        //        log.info("voucherInsert:{}", fxyFinancialVoucher);
        return r;
    }

//    @RequiresPermissions("voucher:voucher:voucherList")
    @PostMapping("/voucherList")
    public R voucherList(@Validated @RequestBody PageDao pageDao) {
        List<FxyFinancialVoucherDetailsVo> fxyFinancialVoucherList = voucherService.voucherList(pageDao);
        return R.ok(fxyFinancialVoucherList);
    }

//    @RequiresPermissions("voucher:voucher:detailsList")
    @GetMapping("/detailsList")
    public R detailsList(){
        List<FxyFinancialVoucherDetails> detailsList = voucherService.detailsList();
        return R.ok(detailsList);
    }
}

